from typing import List

from selenium import webdriver
from selenium.webdriver.common.by import By


class BaseDriver:
    def __init__(self,driver = None):
        if driver is None:
            option = webdriver.ChromeOptions()
            option.debugger_address = '127.0.0.1:9222'
            self.driver = webdriver.Chrome(options=option)
            self.driver.implicitly_wait(5)
            self.driver.get("https://www.ceshiren.com/")

        else:
            self.driver = driver
    # 找单个元素
    def find(self,by,value):
        return self.driver.find_element(by, value)

    # 找到多个元素
    def finds(self,by,value):
        return self.driver.find_elements(by, value)

    # 找到元素并单击
    def find_and_click(self,by,value):
        self.find(by, value).click()

    def find_and_text(self,by,value):
        return self.find(by, value).text

    def find_and_input(self,by,value,text:str):

        return self.find(by, value).send_keys(text)
